码迷,mamicode.com
首页 >  
搜索关键字:function    ( 54714个结果
函数的扩展
函数的扩展 函数参数的默认值 函数参数的默认值 基本用法 基本用法 在ES6之前,不能直接为函数的参数指定默认值,只能采用变通的方法。 function log(x, y) { y = y || 'World'; console.log(x, y); } log('Hello') // Hello ...
分类:其他好文   时间:2016-08-22 23:15:53    阅读次数:165
Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two n ...
分类:其他好文   时间:2016-08-22 23:05:57    阅读次数:139
Leetcode_350_Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as many ti...
分类:其他好文   时间:2016-08-22 21:49:10    阅读次数:106
2016-08-04 PHP函数随笔
函数:1. 封装性 2. 可重用性(变量就是类里面的属性,函数就是类里面的方法)【// 返回两个函数的值$sum = 0;function get_max($a, $b) { global $sum; $c = ($a>$b)?$a:$b; $sum = $a+$b; /* $array = [$c ...
分类:Web程序   时间:2016-08-22 21:35:22    阅读次数:236
数组求和
题目描述 计算给定数组 arr 中所有元素的总和 输入描述: 数组中的元素均为 Number 类型大神代码: function sum(arr) { sum=eval(arr.join('+')); return sum; } 明天补解析; function sum(arr) { sum=eval( ...
分类:编程语言   时间:2016-08-22 20:09:41    阅读次数:160
利用Apply的参数数组化来提高代码的优雅性,及高效性
利用Apply的参数数组化来提高代码的优雅性,及高效性 Function.apply()在提升程序性能方面的技巧 我们先从Math.max()函数说起,Math.max后面可以接任意个参数,最后返回所有参数中的最大值。 比如 alert(Math.max(5,8)) //8alert(Math.ma ...
分类:移动开发   时间:2016-08-22 19:51:02    阅读次数:197
Jqury 初识 -jqury选择元素 、 $()下的常用方法
一.前言:认识jqury jqury: jQuery是一个兼容多浏览器的javascript库,提供了大量实用方法,简化了js操作。它是轻量级的js库 ,它兼容CSS3,还兼容各种浏览器 $( function(){ ... }): 加载完执行 注意:使用jq注意先引入jq库。jq库的版本1(兼容低 ...
分类:其他好文   时间:2016-08-22 19:49:32    阅读次数:193
json和字符串/数组/集合的互相转换の神操作总结
一:前端字符串转JSON的4种方式 1,eval方式解析,恐怕这是最早的解析方式了。 2,new Function形式,比较怪异哦。 IE6/7中当字符串中含有换行(\n)时,new Function不能解析,但eval却可以。 3,使用全局的JSON对象。 目前IE8(S)/Firefox3.5+ ...
分类:编程语言   时间:2016-08-22 18:14:12    阅读次数:174
css兼容处理
1、js判断浏览器是否支持css3属性 function supportCss3(style){var prefix=['webkit','Moz','ms','o'],i,humpString=[],htmlStyle=document.documentElement.style,_toHumb= ...
分类:Web程序   时间:2016-08-22 18:05:00    阅读次数:180
cookie
/* 设置cookie */function setCookie(NameOfCookie, value, expiredays) { var ExpireDate = new Date(); ExpireDate.setTime(ExpireDate.getTime() + (expiredays ...
分类:其他好文   时间:2016-08-22 18:01:57    阅读次数:126
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!