首页 > Web开发 > 详细

2 js的20/80关键知识

时间:2017-12-31 20:35:05      阅读:237      评论:0      收藏:0      [点我收藏+]

1.

 技术分享图片

技术分享图片

技术分享图片技术分享图片

 

 

 

技术分享图片

技术分享图片技术分享图片

 

 

 

2

var a = 1;
undefined
a
1
alert(a);
undefined

  

 技术分享图片

 

var b = true;
var c = "Hi";
undefined
alert(b);
alert(c);
undefined

  

技术分享图片

技术分享图片

 

技术分享图片

技术分享图片技术分享图片

function foo(bar){
	alert(bar);
	return bar;
}
undefined
var z = foo("Hi");
undefined
z
"Hi"

  

function foo(bar)
{
	alert(bar);
	return bar;
}

  

  • shift+enter 换行

 

技术分享图片

 

 

 技术分享图片

技术分享图片技术分享图片

 

 

function foo(bar){
	if (bar > 3){
		alert(bar + 1);
	} else {
		alert("Not enough");
	}
}
undefined
foo(5)
undefined
foo(2);
undefined

  

 技术分享图片

技术分享图片

 

 

 

3

 技术分享图片

 技术分享图片技术分享图片

 

var arr = []
undefined

function foo(bar){
	if (bar > 3){
		arr.push(bar);
	} else {
		alert("Not enough");
		}
}
undefined

foo(2);
undefined

foo(6);
undefined
arr;
[6]

  

技术分享图片

 

技术分享图片

技术分享图片技术分享图片 

var o = {
	one:1,
	two:2
}
undefined
o.one
1
o.two
2

  

 

4

 技术分享图片

技术分享图片

 

 技术分享图片

 

 

技术分享图片

 

 

document
#document

document.querySelector("#sidebar")
<div id=?"sidebar">?…?</div>?

var el = document.querySelector("#sidebar");
undefined

el
<div id=?"sidebar">?…?</div>?

el.setAttribute("style","display:none;")
undefined

  

 技术分享图片

 

 

 

 

5

 

6

 

2 js的20/80关键知识

原文:https://www.cnblogs.com/venicid/p/8158413.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!