GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaScriptNotes/JS高级05.md at master · 7256/JavaScriptNotes

Expand file tree

/

JS高级05.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
86 lines (62 loc) · 2.4 KB
/

JS高级05.md

Copy path

File metadata and controls

86 lines (62 loc) · 2.4 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

JS高级05.md

单体内置对象

Global对象

ECMA中最特别的一个对象,因为不管你从什么角度上看,这个对象都是不存在。在某种意义上是作为一个终极的“兜底儿对象“来定义的。也就是说,不属于任何其他对象的属性和方法,最终都是它的属性和方法。

事实上,没有全局变量或全局函数;所有在全局中用于中定义的属性和函数,都是Global对象的属性。

isNaN()、 isFinite()、parseInt()、parseFloat()全都是Global对象的方法。

URI 编码方法

  • encodeURI 方法:不会对本身属于 URI 的字符进行编码,比如斜杠、冒号、问号、井号之类的。因此这个方法可以对 URI 串进行整体编码
  • encodeURIComponent 方法:会对任何非标准字符串进行编码,因此只能对 URI 的部分串进行编码
var uri = "http://www.wrox.com/illegal_value.htm#start";

//”http://www.wrox.com/illegal%20value.htm#start”
console.log(encodeURI(uri));

//”http%3A%2F%2Fwww.wrox.com%2Fillegal%20value.htm%23start”
console.log(encodeURIComponent(uri));

var uri2 = "http%3A%2F%2Fwww.wrox.com%2Fillegal%20value.htm%23start";
//http%3A%2F%2Fwww.wrox.com%2Fillegal value.htm%23start
console.info(decodeURI(uri2));

//http://www.wrox.com/illegal value.htm#start
console.info(decodeURIComponent(uri2));

eval() 方法

eval("console.info('hi')");

window对象

如果不是在浏览器环境下

var color = “red”;

function sayColor(){
    alert(window.color);
}

window.sayColor(); //”red”

如果不是浏览器环境

var global = function(){

	var color = "red";
	console.info(color);

    return this;
}();
console.info(global);

Global 的属性

PROPERTY DESCRIPTION
undefined The special value undefined
NaN The special value NaN
Infinity The special value Infinity
Object Constructor for Object
Array Constructor for Array
Function Constructor for Function
Boolean Constructor for Boolean
String Constructor for String
Number Constructor for Number
Date Constructor for Date
RegExp Constructor for RegExp
Error Constructor for Error
EvalError Constructor for EvalError
RangeError Constructor for RangeError
ReferenceError Constructor for ReferenceError
SyntaxError Constructor for SyntaxError
TypeError Constructor for TypeError
URIError Constructor for URIError
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.