100 classic examples of native JavaScript organized by WEB front-end engineers

100 classic examples of native JavaScript organized by WEB front-end engineers

I recommend my web front-end learning group: 688676066. Every night at 20:00, I will open a live broadcast to share the web front-end learning knowledge and route methods with you. The group will update the latest tutorials and learning methods from time to time (enter the group to send web front-end learning. Tutorial) Pay attention to weixin, v MicroPort culture, everyone is learning web front-end, or changing careers, or college students, and web parties who want to improve their abilities at work, if you are a small partner who is learning web front-end, you can join Learn. Finally, I wish all programmers to be able to reach the pinnacle of life and let the code shine their dreams into reality.

1. Native JavaScript implements string length interception

100 classic examples of native JavaScript organized by WEB front-end engineers

2. Native JavaScript obtains the domain name host

100 classic examples of native JavaScript organized by WEB front-end engineers

3. Native JavaScript escapes html tags

100 classic examples of native JavaScript organized by WEB front-end engineers

Fourth, the native JavaScript time and date format replacement

Date.prototype.Format = function(formatStr) {

var str = formatStr;

var Week = ['Day', 'One', 'Two', 'Three', 'Four', 'Five', 'Six'];

str = str.replace(/yyyy|YYYY/, this.getFullYear());

str = str.replace(/yy|YY/, (this.getYear() % 100) > 9 ? (this.getYear() % 100).toString() : '0' + (this.getYear() % 100)); str = str.replace(/MM/, (this.getMonth() + 1) > 9 ? (this.getMonth() + 1).toString() : '0' + (this.getMonth() + 1));

str = str.replace(/M/g, (this.getMonth() + 1));

str = str.replace(/w|W/g, Week[this.getDay()]);

str = str.replace(/dd|DD/, this.getDate() > 9 ? this.getDate().toString() : '0' + this.getDate());

str = str.replace(/d|D/g, this.getDate());

str = str.replace(/hh|HH/, this.getHours() > 9 ? this.getHours().toString() : '0' + this.getHours());

str = str.replace(/h|H/g, this.getHours());

str = str.replace(/mm/, this.getMinutes() > 9 ? this.getMinutes().toString() : '0' + this.getMinutes());

str = str.replace(/m/g, this.getMinutes());

str = str.replace(/ss|SS/, this.getSeconds() > 9 ? this.getSeconds().toString() : '0' + this.getSeconds());

str = str.replace(/s|S/g, this.getSeconds());

return str

5. Native JavaScript determines whether it is a numeric type

100 classic examples of native JavaScript organized by WEB front-end engineers

6. Native JavaScript gets cookie value

100 classic examples of native JavaScript organized by WEB front-end engineers

Seven, native JavaScript formatting CSS style code

100 classic examples of native JavaScript organized by WEB front-end engineers

Eight, native JavaScript to achieve checkbox select all or not select all

100 classic examples of native JavaScript organized by WEB front-end engineers

9. Native JavaScript retrieves element objects based on style names

100 classic examples of native JavaScript organized by WEB front-end engineers

10. Native JavaScript determines whether it starts with a certain string

100 classic examples of native JavaScript organized by WEB front-end engineers

Eleven, native JavaScript to get the page scrollLeft

100 classic examples of native JavaScript organized by WEB front-end engineers

12. Native JavaScript cross-browser add events

100 classic examples of native JavaScript organized by WEB front-end engineers

13. Native JavaScript uses regular expressions to clear the same array (high efficiency)

100 classic examples of native JavaScript organized by WEB front-end engineers

If there are front-end programmers who are interested in front-end, you can come to our web front-end technology learning group 688676066, which will provide free front-end zero-based tutorials!


Write at the end:


Many people know that I am learning the full stack, and they all naively think that I have a full set of video learning materials such as front-end and web page production. I want to say you guys are right, I do have the full set of video stuff on the front end.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324893946&siteId=291194637