JavaScript:Object.prototype.toString方法的原理
摘要:在JavaScript中,想要判断某个对象值属于哪种内置类型,最靠谱的做法就是通过Object.prototype.toString方法.var arr = [];console.log(Object.prototype.toString.call(arr)) //”[object Array]“本文要讲的就是,toString方法是如何做到这一点的,原理是什么.ECMAScript 3在ES3中,Object.prototype.toString方法的规范如下:15.2.4.2 Object.prototype.toString()在toString方法被调用时,会执行下面的操作步骤:1.
阅读全文
javascript中的封装,多态,继承
摘要:封装Encapsulation如下代码,这就算是封装了(function (windows, undefined) { var i = 0;//相对外部环境来说,这里的i就算是封装了})(window, undefined);继承Inheritance(function (windows, undefined) { //父类 function Person() { } Person.prototype.name = "name in Person"; //子类 function Student() { } Student.prototype = new...
阅读全文
理解Linq和lambda
摘要:******************理解Linq和lambda***********************using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace LinqYL{ public delegate bool Func2<T>(T t); public static class Enumerable { public static IEnumerable<T> Where2<T>(this IEnumerable<
阅读全文
一道个人感觉比较有水平的JS面试题,反正我看错了
摘要:<script>var length=100;function A(){alert(this.length);}function B(a){this.length=10;arguments[0]();}var b=new B(A);//10 </script>
阅读全文