共 18 篇文章
显示摘要每页显示  条
例子:/(foo) (bar) \1 \2/.test(''bar foo bar foo''); // false/(bar) (foo) \1 \2/.test(''bar foo bar foo''); // true/(bar) (foo) \1 \2/.test(''bar foo''); // false/(bar) (foo) \1 \2/.test(''bar foo foo bar''); // false/(bar) (foo) \2 \1/.test(''bar...
function foo(){ console.log(this.count) // 1 console.log(foo.count) // 2}var count = 1foo.count = 2foo()function foo(){ ''use strict'' console.log(this.count) // TypeError: count undefined}var count = 1foo()3.1.2 隐式绑定。function foo(){ console.log(this.count) // 1}var count = 1var obj = { count: 2, ...
转换成字符串(tostring)// numbervar iNum = 10;alert(iNum.toString()); //输出 ''10''//Booleanvar bool = false;alert(bool .toString()); //输出 ''false''//基模式var iNum = 10;alert(iNum.toString(2)); //输出 ''1010''alert(iNum.toString(8)); //输出 ''12''aler...
响应某个事件的函数则称为事件处理程序,或者叫做事件侦听器。其实它就是我们平时最为常用的事件绑定,如下面这个例子:<!doctype html><html><head> <meta charset="UTF-8"> <title>事件-独行冰海</title></head><body> <p id=‘btn‘>DOM0级事件处理程序</p>...
例如:console.log(a); // undefinedvar a = ''hello'';# 上面的代码相当于var a;console.log(a);a = ''hello'';# 而 let 就不会被变量提升console.log(a); // a is not definedlet a = ''hello'';对象字面量简写(省略冒号与 function 关键字)// ES5var people1 = { name: ''bai...
2017年前端框架、类库、工具大比拼。相比于JavaScript开发人员的数量,目前JavaScript框架、类库和工具的数量似乎更多一些。框架可以包括一个类库,类库可以实现类似框架的方法,项目中任何一种工具都是必不可少的。github.com/angular/angular.js。Angular是框架(或MVC应用程序框架)类列表中的第一个。Backbone.js声称是一个类库,因为它可...
^ 表示字符串的开始位置 $ 表示字符串的结束位置// test必须出现在开始位置/^test/.test(''test123'') // true// test必须出现在结束位置/test$/.test(''new test'') // true// 从开始位置到结束位置只有test/^test$/.test(''test'') // true/^test$/.test(''test test'') //...
个人理解这时候i只是一个局部变量,如果不打上断点,浏览器会把所有的js全部解析完成,console并不能访问到局部变量,只能访问到全局变量,所以这时候console会报错i未定义,但是当js打上断点时,console解析到了局部变量i所在的函数内,这时候i是能够被访问的。这个按钮我称呼它为“逐过程执行”按钮,和“逐语句执行”按钮不同,“逐过程执行...
JavaScript:为什么3 true=4?console.log(3 + true);// 4console.log(3 + true == 4);// 1console.log(true + true);当一个 + 运算符放置在一个 string 和 number 或 boolean 之间时, number 和 boolean 将变成一个 string 。console.log(true + ''4'');// true4console.log(''4'' + true);注意:如果 boolea...
javascript 动态修改css样式方法汇总(四种方法)2、使用obj.style.cssTest来修改嵌入式的css。方法二、使用obj.style.cssTest来修改嵌入式的css.1、obj.className = "style2"; 2、 obj.setAttribute("class", "style2");都是一样的效果。<link href="css1.css" rel="stylesheet" type=&q...
帮助 | 留言交流 | 联系我们 | 服务条款 | 下载网文摘手 | 下载手机客户端
北京六智信息技术股份有限公司 Copyright© 2005-2024 360doc.com , All Rights Reserved
京ICP证090625号 京ICP备05038915号 京网文[2016]6433-853号 京公网安备11010502030377号
返回
顶部