
javascript
沙漠662
自学javaEE
展开
-
js中apply的妙用
/* 我们先从Math.max()函数说起, Math.max后面可以接任意个参数,最后返回所有参数中的最大值。 比如*/ console.log(Math.max(5,8)) //8 console.log(Math.max(5,7,9,3,1,6)) //9 /*问题:如何获取一个数组的最大值*/ /*遍历*/ /* 但是在很多情况下,我们需要原创 2016-06-07 21:51:58 · 749 阅读 · 0 评论 -
js aop 写法
//给函数扩展方法Function.prototype.before = function( func ) { var __self = this; return function() { if ( func.apply( this, arguments ) === false ) { return false; }原创 2016-10-09 17:02:56 · 484 阅读 · 0 评论 -
闭包类 demo
Documentvar Student = (function(){ var num = 0; return function(name, age){ num++; console.log("num=="+num) var chineseAge; this.name = name; this.age = age; chineseAge = age; thi原创 2016-07-28 11:21:28 · 536 阅读 · 0 评论 -
javascrip常用功能封装框架
/*多立即函数放置扩展函数*/(function(){ stringExtend() arrayExtend() functionExtend() function stringExtend(){ /*新增一个方法*/ String.prototype.formateString=function(data){原创 2016-05-22 21:26:00 · 1429 阅读 · 0 评论 -
Array常用功能扩展.js
/** 删除数组中指定索引的数据 **/Array.prototype.deleteAt = function (index) { if (index < 0) { return this; } return this.slice(0, index).concat(this.slice(index + 1, this.length));}/** 数组洗原创 2016-05-22 21:22:47 · 315 阅读 · 0 评论 -
常用string原型扩展js
/** 在字符串末尾追加字符串 **/String.prototype.append = function (str) { return this.concat(str);}/** 删除指定索引位置的字符,索引无效将不删除任何字符 **/String.prototype.deleteCharAt = function (index) { if (index = this.l原创 2016-05-22 21:21:17 · 3022 阅读 · 0 评论 -
js 案例
//产品对象/*对象内如何使用对象的属性和方法:this,对象外如何使用:先实例化,后用点语法*/function Product() { /*属性 行为*/ this.name =''; this.price=''; this.description = ''; this.youhuijia=''; this.zhekou = '' t原创 2016-05-21 20:06:32 · 313 阅读 · 0 评论 -
JS 闭包类
Documentvar Student = (function(){ var num = 0; return function(name, age){ num++; var chineseAge; this.name = name; this.age = age; chineseAge = age; this.getChineseAge = function(原创 2016-05-21 19:32:02 · 657 阅读 · 0 评论 -
JS调用函数的5中方式
/****************************************************************************** 普通模式 ******************************************************************原创 2016-06-07 21:53:12 · 261 阅读 · 0 评论 -
div滚动条在最低端
/* */ //div滚动条(scrollbar)保持在最底部 function scrollToBottom(){ //var div = document.getElementById('chatCon'); var div = document.getElementById('up'); div.scrollTop = div.scr原创 2016-12-19 14:48:49 · 1924 阅读 · 0 评论