Home>Article>Web Front-end> Part 1 Quick Start—Date, Math, and Global objects in js basic practice
tool.js
function print(str){ document.write(str); } function println(str){ document.write(str+"
"); } ///////通过prototype属性扩展js API的对象的功能///////// //※把trim方法融入到String对象中: str.trim() String.prototype.trim = function(){ var start=0;//第一个非空格字符的位置 var end=this.length-1;//最后一个非空格字符的位置 while(start<=end && this.charAt(start)==' '){ start++; } while(start<=end && this.charAt(end)==' '){ end--; } return this.substring(start,end+1); }; //给String对象添加一个toCharArray()方法 String.prototype.toCharArray = function(){ var chs=[]; for(var x=0;xlen2?len2:len1; var longLen=len1>len2?len1:len2; for(var i=0; i len2){ return 1; }else if(len1 Objects in JS language--Date object
JS语言中的对象--Date对象
Objects in JS language- -Math object
JS语言中的对象--Math对象 Objects in JS language--Global object, top-level function (global function)
js puts some common functions It is defined in an object called Global, and "Global." cannot be written when calling.
eval(str): Treat the string as a js statement to evaluate and execute
Number(s): Convert the parameter s into "Value (value of type Number)", if the parameter is a Date, the millisecond value is returned. If the parameter cannot be converted into a value, it is returned: NaN
parseFloat(): Parse a string and Returns a floating point number.
JS语言中的对象--Global对象, 顶层函数(全局函数)
Related articles:
Part 2 Quick Start—JS Basics Practical BOM--Browser Object Model, DOM
Part 3 Quick Start—JS Basic Practical Application Code Sharing
Related Videos:
27 Classic Practical Video Tutorials for Front-end JS Development-Free Online Video Tutorial
The above is the detailed content of Part 1 Quick Start—Date, Math, and Global objects in js basic practice. For more information, please follow other related articles on the PHP Chinese website!