Js Quiz

来源:互联网 发布:mac火鹤色口红图片 编辑:程序博客网 时间:2024/05/22 03:27

Please first execute the two parts codes in one group then think about why ?

1.

  function g(){ return 23; };  var f = g;  typeof g();

VS

  var f = function g(){ return 23; };  typeof g();


2.

function fun1(para){  this.testNumber = para;}function fun2(para){  this.testString = para;}fun1.prototype = new fun2("stringvalue");var myf1 = new fun1(3);var v = myf1.testNumber;var s = myf1.testString;console.log(v+"~"+s+"~"+typeof fun1.prototype);

VS

function fun1(para){  this.testNumber = para;}function fun2(para){  this.testString = para;}//fun1.prototype = new fun2("stringvalue");var myf1 = new fun1(3);var v = myf1.testNumber;var s = myf1.testString;console.log(v+"~"+s+"~"+typeof fun1.prototype);