javascript需要记忆又容易被忽视的基础
2017-02-22 08:16
357 查看
本文只做偶尔翻看记忆
区分大小写标识符
第一个字符必须是一个字母、下划线或一个美元符号。
其他字符可以使字母、下划线、美元符号或数字。
数据类型
5种简单数据类型:Undefined、Null、Boolean、Number、String
1种复杂数据类型:Object
创建global对象
var global = function(){ return this; }();
获取数组最大最小值
var arr = [3,4,6,7,8,3,2,5];//数字或字符串皆可 var max = Math.max.apply(Math , arr); Array.prototype.max = function(){ var max = Math.max.apply(Math , this); return max; } var arr = [3,4,6,7,47,3,2]; console.log(arr.max());
数据属性
configurable 是否能通过deltete删除
enumerable 是否能通过for-in循环
writable 是否能修改
value
Object.defineProperty()
如果通过defineProperty()设置属性为false只有第一次调用defineProperty()才生效,再次调用修改相同的属性可能会报错。
var person = {}; Object.defineProperty(person , 'name' , { writable : false, value : 'magic' }); console.log(person.name);//magic person.name = 'bob'; console.log(person.name);//magic
与之类似的还有访问其属性。get,set也可以通过defineProperty()设置。
读取属性特点
Object.getOwnPropertyDescriptor()。 接受两个参数 , 要读取的对象, 要读取的属性名称。
相关文章推荐
- C++容易被忽视的基础知识
- html基础 javascript:window.close()在火狐浏览器中不起作用 ---需要设置浏览器参数
- 需要牢记的JavaScript基础知识
- 前端程序员容易忽视的一些基础知识
- JavaScript-需要的基础DOM特性
- html基础 javascript:window.close()在火狐浏览器中不起作用 ---需要设置浏览器参数
- 前端程序员容易忽视的一些基础知识
- Javascript 容易忽视的语法点
- JavaScript[容易忽视的错误]:当续行遇到换行,换行符丢失
- JavaScript 基础知识之对比记忆学习
- 认识PHP代码标识 想在页面中编写PHP代码非常容易,如下面代码: <?php echo "想学习php吗?来慕课网吧"; ?> 就像你可以编写JavaScript脚本语言需要写在<scri
- 接触javascript很久了,每次理解闭包都似是而非,最近在找Web前端的工作,所以需要把基础夯实一下。 本文是参照了joy_lee的博客 闭包 在她这篇博客的基础上以批注的形式力争把我的理解阐述出
- 一个JavaScript组件都需要哪些基础api
- 语言 基础 容易忽视的
- javascript面向对象技术基础(是我需要的)
- javascript 容易忽略或者误用的七个基础知识点
- JavaScript中的一些重要却容易被忽视的东西
- JavaScript中容易忽视的高效操作——位操作
- Javascript中容易被忽视的地方
- 前端程序员容易忽视的一些基础知识