js面试真题

1.const aaa={

      sss:'xxx'

};

Const bbb={

    xxx:1

};

Bbb.aaa.sss//undefined.sss

 

Let   a={aa:1};//引数数据类型

Let b=a;

a.aa=2;

b.aa//2

 

 

 

Let   aa

aa={}

Console.log(aa)//{}

Let a;

Console.log(a)//

Function fn(m,n){

This.x=m;

This.y=n

}

Let a=new fn();

a.getname=()=>{}

Console.log(a.getname)//typeError;

 

a.prototype.getname()=>{}

 

Let a =new fn(1,2)//fn{x:1,y:2}     new关键字 创建新对象{}

Let b=fn(3,4);//undefined   你没有new  全局变量;

事件传播的三级阶段: 捕获  目标  冒泡;默认 :目标,冒泡;

所有的对象都有原型?错,除了基础对象,基础对像指原型链重点的对象,基础对象的原型是null

 

Function  fn(a,b,c){console.log(a);~log(b);~log(c)};

Const x='jk';

Const y=21;

 

Fn '${x}' is '$(y)' years old;//[''  is   years old]  jk   21;

如果使用标记的模板字符串,则第一个参数的初始值始终 是字符串值的数组。

{a:1}=={}   {}==={} 都等于false

 

 

 

 

Function fn(…args){console.log(typeof args)}// typeof []//'object';

Function fn(){

'use strict'

Age=21;

Console.log(age)//referenceErro

}

 

function a(){console.log('aa')}

a.b='bbb'

//bbb

 

 

Class    fn{

   static   f1(){}

}

Let aa=new fn

Aa.f1()//typeEeror   静态方法仅创建与构造函数中,并且不能传递个任何子级。
 

Let a=1;

Let a=2;

Console.log(a)//error  a 已经被定义;

Const obj={a:1,b:2,a:3};//{a:3,b:2}

 

Var  a=1;

Var a=2;

 

Console.log(a)//2;

Const a={};

Const b={};

Const c={};

a[b]=123;

A[c]=456

Console.log(a[b])//a['object','object']456

 

 

 

<div onclick='console.log(div)'>

        <p onclick='console.log(p)'>xxx</p>

</div>

 

事件传播有三阶段:捕获  目标  冒泡;

默认情况下,事件处理程序是在冒泡开始的  所以  :  p   div

 

 

Function  fn(){

  return (()=>0)()

}

Typeof fn()    //number

 

 

假值类型:js中有6个:undefined null   ''  false    0  nan ;

New Number(0)和new boolean(false)//为真值;

js只有原始类型和对象

[…'jack'];//['j',….,'k']

Const obj={1:'a',2:'b'};

Const  set =new set([1,2,3]);

Obj.hasOwnproperty('1')//true    所有的对象键都会被存储为字符串,即使没有定义为字符串;

Obj.hasOwnproperty(1);//true

Set.has(1);//true

Set.has('1')//false

原文地址:https://www.cnblogs.com/yancongyang/p/11170089.html