关于变量和函数的提升测试题

//   var a = 1;

//   function fn(a) {
//       /* 参数a重新定义了函数内的a 函数内部的a无法改变全局变量a的值 */
//       /* var a = 1 */
//       console.log(a);/* 1 */
//       a = 2
//       console.log(a);/* 2 */
//   }
//   fn(a);
//   console.log(a);/* 1 */

//   var a=1
//   function fn(){
//       console.log(a)/* undefined 如果函数内未定义a 就是全局变量的值 */
//       var a = 2;
//   }
//   fn()







//   var a = 1;

//   function fn() {
//       console.log(a);/* undefined */
//       var a = 2;
//       console.log(a);/* 2 */
//   }
//   fn()
//   console.log(a);/* 1 */






//   var a = 1

//   function fn() {
//       console.log(a);/* 1 */
//       a = 2
//       console.log(a);/* 2 */
//   }
//   fn()
//   console.log(a);/* 2 */






//   alert(a);/* 函数体 */
//   a();/* 执行最后一个有名函数  弹出5 */
//   var a = 3;

//   function a() {
//       alert(10);/* 不执行 */
//   }
//   alert(a);/* 变量3 */

//   function a() {
//       alert(5);/* 上边执行完毕 */
//   }
//   a = 6;
//   alert(a);/* 6 */
//   var a = function() {
//       alert(8);/* 8 */
//   }
//   a();





//   function b() {
//       console.log(a);/* 函数体 因为变量和函数同时存在时 优先解读 */
//       var a = 10;

//       function a() {};
//       a = 100;
//       console.log(a);/* 100 */
//   }
//   b();





//   (function() {
//       var a = b = 3;
//   })();
//   console.log(b);/* 3 */

//   console.log(typeof a);/* undefined  如果运算数是没有定义的(比如说不存在的变量、函数或者undefined),将返回undefined。 */
//   console.log(typeof b);/* number */
//   console.log(typeof a !== 'undefined');/* f */
//   console.log(typeof b !== 'undefined');/* t */






  /* function fn() {
      alert(1);
  }
  fn();

  function fn() {
      alert(2);
  }
  fn(); */






//   var x = 0;
//   var y = 0;
//   var z = 0;

//   function add(n) {
//       n = n + 1;
//       return n;
//   }

//   y = add(x);/* 执行下边的add函数  下边函数没有返回值 */

//   console.log(y);

//   function add(n) {
//       n = n + 3;
//   }

//   z = add(x);

//   console.log(z);






//   console.log(total);/* undefined */
//   var total = 0;

//   function func(num1, num2) {
//       console.log(total);/* undefined 函数内部重新定义total */
//       var total = num1 + num2;
//       console.log(total);/* 300 */
//   }
//   func(100, 200);
//   console.log(total);/* 0 */




//   alert(a);/* undefined */
//   var a = 0;
//   alert(a);/* 0 */

//   function fn() {
//       alert(a);/* 0 */
//       a = 2;
//       alert(a);/* 2 */
//   }
//   fn()
//   alert(a);/* 2 */




  // alert(a);/* undefined */
  // var a = 0;
  // alert(a);/* 0 */

  // function fn() {
  //     alert(a);/* undefined */
  //     var a = 2;
  //     alert(a);/* 2 */
  // }
  // fn()
  // alert(a);/* 0 */

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当数据存在主次表时,当更新了次表数据后,主表数据在后台有更变时。可利用刷新主表当前行的方法重显主表数据。 /************************************************************ 函数名称: f_refresh_currentrow(adw) 功 能: 刷新DW当前行数据,不可刷新NO update or 带arguments的DW 参数说明: adw 目标DW 返 回 值: integer 成功返回1,失败返回-1 作 者: sean 创建时间: 2010年8月18日 ************************************************************/ string ls_dataobject string ls_keys[] //key Column Name string ls_dbname[] //key field Name string ls_coltype[] //field style string ls_tablenm //table name string ls_condition //sql Condition long ll_currentrow //Current Row numeric long ll_column //Column count integer i datawindow ldw datastore ldatastore ldw=adw if ldw.rowcount( )=0 then return -1 elseif trim(ldw.describe( "datawindow.table.arguments"))<>'?' then messagebox('','刷新数据窗口当前行失败!,数据窗口需要参数',exclamation!) return -1 else ll_currentrow=ldw.getrow( ) FOR ll_column = 1 TO long(ldw.object.datawindow.column.count)//key names If ldw.Describe("#"+string(ll_column)+".key") ='yes' Then i++ ls_keys[i]=ldw.Describe("#"+string(ll_column)+".name") ls_dbname[i]=ldw.Describe("#"+string(ll_column)+".dbname") ls_coltype[i]=ldw.Describe("#"+string(ll_column)+".coltype") End If NEXT if upperbound(ls_keys[])=0 then messagebox('','刷新数据窗口当前行失败!,没有主键',exclamation!) return -1 else ls_tablenm=left(ls_dbname[1],pos(ls_dbname[1],'.') -1) //table name for i=1 to upperbound(ls_keys[]) if pos('numb,deci,long,',LeftA(ls_coltype[i],4) +',')>0 then ls_condition+="and "+ls_dbname[i]+"="+string(f_getitem(ldw,ll_currentrow,ls_keys[i])) else ls_condition+="and "+ls_dbname[i]+"='"+string(f_getitem(ldw,ll_currentrow,ls_keys[i]))+"'" end if next ls_condition=mid(ls_condition,4) //sql Condition ldatastore=create datastore ldatastore.dataobject=ldw.dataobject ldatastore.settransobject( sqlca) if f_addwhere_retrieve(ldatastore,ls_condition)=1 then if ldatastore.rowcount( )=1 then ldw.object.data[ll_currentrow]=ldatastore.object.data[1] ldw.setitemstatus( ll_currentrow, 0, primary!, NotModified!) //if ldw.getrow( )<>ll_currentrow then ldw.scrolltorow( ll_currentrow) end if else messagebox('','刷新数据窗口当前行失败!,条件语法错误',exclamation!) return -1 end if destroy ldatastore end if end if
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值