javascript计算字符串长度 学习了:https://blog.csdn.net/u012934325/article/details/75214847 function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; } else { len += 1…
In JavaScript, we often end up composing one object out of several other objects. Luckily there's a convenient spread operator which allows us to spread entries from one object to another. Sometimes we only want to include something in the newly crea…
The registration of callback functions is very common in JavaScript web programming, for example to attach user interface event handlers (such as onclick), or to provide a function to handle an XHR response. Registering an object method as a callback…
---------------------------------ajaxUtil----------------------------------------------------------------------------------- // ajaxUtil.js var debug = true; function sendHttpRequest(method, url, params, callback) { var request; if (window.XMLHttpReq…
<html> <head> <meta charset="UTF-8"/> <title>截取字串长度</title> </head> <body> <script type="text/javascript"> function cutStr(str,len){ var temp=''; ; var pattn=/[^\x00-\xff]/; var strre='';…
let person = { firstName: "Zhentian", lastName: "Wan" }; /*Object.freeze() makes object cannot be updated, added or deleted*/ let freezePerson = Object.freeze(person); freezePerson.address="Finland"; // Cannot add property ad…
Best Pratices for Object.assign: http://www.cnblogs.com/Answer1215/p/5096746.html Object.assign() can extend the object by adding new props: let obj = { first_name: 'Zhentian', age: 27 } Object.assign(obj, {last_name: 'Wan'}); console.log(obj); log o…