当开发者写浏览器js时,一些很好内置函数有些浏览器实现了有些却没实现,这样导致程序员根本就不用这些函数。
如果你在玩nodejs,可以确定这的是这些好用的内置函数都被统一的实现,不需要自己一遍一遍自己实现。
下面的列出一些非常好用的api 片段 ,这些方法在v8里内置实现了。
注意:v8 实现了ECMA 3 所有规范,但是仅仅实现了ECMA 5规范部分内容
语法扩展
var obj = { get a() { return "something" }, set a() { "do nothing" } }
getter/setter 方法定义
Array
-
Array.isArray(array)
– 数组判断.
Array.prototype
-
indexOf(value)
– Returns the first (least) index of an element within the array equal to the specified value, or -1 if none is found.
-
lastIndexOf(value)
– Returns the last (greatest) index of an element within the array equal to the specified value, or -1 if none is found.
-
filter(callback)
– Creates a new array with all of the elements of this array for which the provided filtering function returns true.
-
forEach(callback)
– Calls a function for each element in the array.
-
every(callback)
– Returns true if every element in this array satisfies the provided testing function.
-
map(callback)
– Creates a new array with the results of calling a provided function on every element in this array.
-
some(callback)
– Returns true if at least one element in this array satisfies the provided testing function.
-
reduce(callback[, initialValue])
– Apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value.
-
reduceRight(callback[, initialValue])
– Apply a function simultaneously against two values of the array (from right-to-left) as to reduce it to a single value.
Date
-
Date.now()
– Returns the numeric value corresponding to the current time.
Date.prototype
Object
-
Object.create(proto, props)
– Creates a new object whose prototype is the passed in parent object and whose properties are those specified by props.
-
Object.keys(obj)
– Returns a list of the ownProperties of an object that are enumerable.
-
Object.defineProperty(obj, prop, desc)
– Defines a property on an object with the given descriptor
-
Object.defineProperties(obj, props)
– Adds own properties and/or updates the attributes of existing own properties of an object
-
Object.getOwnPropertyNames(obj)
– Returns a list of the ownProperties of an object including ones that are not enumerable.
-
Object.getPrototypeOf(obj)
– Returns the prototype of an object.
-
Object.getOwnPropertyDescriptor(obj, property)
– Returns an object with keys describing the description of a property (value, writable, enumerable, configurable)
-
Object.preventExtensions(obj)
– Prevents any new properties from being added to the given object.
-
Object.isExtensible(obj)
– Checks if Object.preventExtensions() has been called on this object.
-
Object.seal(obj)
– Prevents code from adding or deleting properties, or changing the descriptors of any property on an object. Property values can be changed however.
-
Object.isSealed(obj)
– Checks if Object.seal() has been called on this object.
-
Object.freeze(obj)
– Same as Object.seal, except property values cannot be changed.
-
Object.isFrozen(obj)
– Checks if Object.freeze() has been called on this object.
Object.prototype
-
__defineGetter__(name, callback)
– (Mozilla extension, not ECMAScript 5) Associates a function with a property that, when accessed, executes that function and returns its return value.
-
__defineSetter__(name, callback)
– (Mozilla extension, not ECMAScript 5) Associates a function with a property that, when set, executes that function which modifies the property.
-
__lookupGetter__(name)
– (Mozilla extension, not ECMAScript 5) Returns the function associated with the specified property by thedefineGetter method.
-
__lookupSetter__(name)
– (Mozilla extension, not ECMAScript 5) Returns the function associated with the specified property by thedefineSetter method.
-
isPrototypeOf(obj)
– (EcmaScript 3 and 5) Returns true if this
is a prototype of the passed in object.
Function.prototype
-
bind(thisArg[, arg1[, argN]])
– Sets the value of ‘this’ inside the function to always be the value of thisArg when the function is called. Optionally, function arguments can be specified (arg1, arg2, etc) that will automatically be prepended to the argument list whenever this function is called.
JSON
-
JSON.stringify(obj)
– Takes any serializable object and returns the JSON representation as a string.
-
JSON.parse(string)
– Takes a well formed JSON string and returns the corresponding JavaScript object.
String.prototype
-
trim()
– Trims whitespace from both ends of the string
-
trimRight()
– Trims whitespace from the right side of the string
-
trimLeft()
– Trims whitespace from the left side of the string
Property Descriptor Defaults
-
value
– undefined
-
get
– undefined
-
set
– undefined
-
writable
– false
-
enumerable
– false
-
configurable
– false
Missing features
-
Object.__noSuchMethod__
(Mozilla extension, not ECMAScript 5)
-
"use strict";
syntax extension (v8 issue)
分享到:
相关推荐
nodejs google v8引擎的服务器端js实现,强悍的服务器端脚本,让JS无所不能
这两天学习了nodejs mysql 实现分页,很重要,所以,今天添加一点小笔记。 代码如下 var express = require('express'); var router = express.Router(); var settings = require('../settings.js'); var mysql =...
文件上传是一个比较常见的功能,传统的选择方式的上传比较麻烦,需要先点击上传按钮,然后再找到文件的路径,然后上传。给用户体验带来很大问题。...结合html5、nodejs express实现了拖拽上传的功能。
nodejs实现websocket服务与html+js聊天通信示例 1.先装一个nodeJs的模块,叫nodejs-websocket . 2.直接在nodeJs命令行中敲入:npm install nodejs-websocket回车就可以安装好了. 3.开始建立服务器了,因为有了nodejs...
一个用NodeJS实现的Ftp Servce
在本文中,我们将深入探讨如何使用NodeJS和Vue.js实现在沙箱环境中集成支付宝支付的完整流程。这个项目涉及的主要知识点包括NodeJS后端开发、Vue.js前端开发以及支付宝开放平台的API接口调用。 首先,我们需要理解...
快递鸟api,查询物流,nodejs实现
NodeJs实现水仙花数,模块化
nodejs的一个小代码,使用nodejs代码实现图片的上传
文件上传是一个比较常见的功能,传统的选择方式的上传比较麻烦,需要先点击上传按钮,然后再找到文件的路径,然后上传。给用户体验带来很大问题。...结合html5、nodejs express实现了拖拽上传的功能。
nodeJS,下载即可安装,无需配置环境变量,安装后,默认路径安装,即可运行。
基于vue+elementui+nodejs+mysql实现的仓库管理系统源码.zip 该项目是个人毕设项目,答辩评审分达到95分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。 该资源主要针对计算机、通信、...
node-canvas, node Canvas是一个Cairo支持的NodeJS画布实现 节点画布这是版本 2.0.0 -alpha的文档Alpha版本的2.0可以使用 npm install canvas@next 安装。有关从 1.x 升级到 2. x.的指南,请参阅变更日志版本 1.x ...
椭圆加密国密SM2 Nodejs实现源代码,密钥生成,从私钥计算公钥,签名,验签,同时包含secp256和secp192
电信lot 接口帮助类,nodejs实现
NodeJs实现读取目录文件(node dir_new list),以及文件批量生成(node dir_new)
【资源介绍】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、...基于 TensorFlowJS 实现的 face-api.js 人脸识别库(使用 Vue 框架搭建演示,H5、Web、NodeJS 实现人脸检测识别).zip
vue+nodejs实现图片上传并顺序浏览 vue+nodejs实现图片上传并顺序浏览 vue+nodejs实现图片上传并顺序浏览 vue+nodejs实现图片上传并顺序浏览 vue+nodejs实现图片上传并顺序...
使用nodejs下载网站中的图片,nodejs爬图
使用nodejs实现一个简单的爬虫适用于想了解node 爬虫等入门的同学学习使用