真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

javascript手寫,js手寫代碼

【前端面試:手寫js系列】flat---數(shù)組扁平化

數(shù)組扁平化定義:在前端項目開發(fā)過程中,偶爾會出現(xiàn)層疊數(shù)據(jù)結(jié)構(gòu)的數(shù)組,需要把多層數(shù)組轉(zhuǎn)換為一級數(shù)組(即提取嵌套數(shù)組元素最終合并為一個數(shù)組),使其內(nèi)容合并并且展開。

成都創(chuàng)新互聯(lián)服務(wù)項目包括固鎮(zhèn)網(wǎng)站建設(shè)、固鎮(zhèn)網(wǎng)站制作、固鎮(zhèn)網(wǎng)頁制作以及固鎮(zhèn)網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,固鎮(zhèn)網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到固鎮(zhèn)省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

遍歷數(shù)組的方案:

for循環(huán)

for...of

for...in

forEach()

entries()

keys()

values()

reduce()

map()

判斷元素是否是數(shù)組的方案:

instanceof

constructor

object.prototype.toString.call

isArray

將數(shù)組元素進行展開一層的方案:

擴展運算法 + concat(concat() 方法用于合并兩個或多個數(shù)組,在拼接的過程中加上擴展運算符會展開一層數(shù)組)

concat + apply(主要是利用 apply 在綁定作用域時,傳入的第二個參數(shù)是一個數(shù)組或者類數(shù)組對象,其中的數(shù)組元素將作為單獨的參數(shù)傳給 func 函數(shù)。也就是在調(diào)用 apply 函數(shù)的過程中,會將傳入的數(shù)組一個一個的傳入到要執(zhí)行的函數(shù)中,也就是相當對數(shù)組進行了一層的展開。)

toString + split(不推薦使用 toString + split 方法,因為操作字符串是很危險的事情,如果數(shù)組中的元素所有都是數(shù)字的話,toString + split 是可行的,并且是一步搞定。)

最終手寫的flat()方法為:

參考博客如下,注明一下出處,感謝大神們,希望自己可以多多練習,多多回顧:

三元博客

JS數(shù)組reduce()方法詳解及高級技巧

數(shù)組flat方法實現(xiàn)

javascript,移動劃過超鏈接鼠標變手型

用css控制鼠標樣式的語法如下:

span style="cursor:*"文本或其它頁面元素/span

把 * 換成如下15個效果的一種:

下面是對這15種效果的解釋。移動鼠標到解釋上面,看看你的鼠標起了什么變化吧!

hand是手型

pointer也是手型,這里推薦使用這種,因為這可以在多種瀏覽器下使用。

crosshair是十字型

text是移動到文本上的那種效果

wait是等待的那種效果

default是默認效果

help是問號

e-resize是向右的箭頭

ne-resize是向右上的箭頭

n-resize是向上的箭頭

nw-resize是向左上的箭頭

w-resize是向左的箭頭

sw-resize是左下的箭頭

s-resize是向下的箭頭

se-resize是向右下的箭頭

auto是由系統(tǒng)自動給出效果

原生JS是自己手寫的JS嗎?

原生js就是使用javascript來進行一系列的開發(fā),

非原生就是使用了js框架,像jq等就不是原生的,它是js的封裝。

能發(fā)一下手寫輸入的JS代碼給我嗎

給你JS,這個是用在opera下的手寫輸入,按住ctrl+鼠標左鍵呼出

——————————————————————————————

// ==UserScript==

// ==/UserScript==

SWFObject = function($) {

this.cfg = $;

this.swfId = $.fid;

this.asObjects = {};

this.onLoadInit = null;

SWFObject.instances[this.swfId] = this

};

SWFObject.prototype.load = function() {

Utils.f(this.cfg)

};

SWFObject.prototype.getASObject = function($) {

return this.asObjects[$.asoId]

};

SWFObject.prototype.registerASObject = function(A) {

var _ = A.asoId,

$ = this.swfId;

return this.asObjects[_] = new ASObject({

asoId: _,

swfId: $

})

};

SWFObject.prototype.getASObjectProperty = function($) {

if (this.swf == null) this.swf = Utils.g(this.swfId);

return this.swf.getASObjectProperty($)

};

SWFObject.prototype.setASObjectProperty = function($) {

if (this.swf == null) this.swf = Utils.g(this.swfId);

this.swf.setASObjectProperty($)

};

SWFObject.prototype.callASObjectMethod = function($) {

if (this.swf == null) this.swf = Utils.g(this.swfId);

return this.swf.callASObjectMethod($)

};

SWFObject.instances = {};

SWFObject.getSWFObject = function($) {

return SWFObject.instances[$.swfId]

};

SWFObject.dispatchASObjectEvent = function(B) {

var _ = B.swfId,

A = B.asoId,

F = B.type,

E = B.data,

C = SWFObject.getSWFObject({

swfId: _

}),

$ = (A == undefined) ? C: C.getASObject({

asoId: A

}),

D = "on" + F.substr(0, 1).toUpperCase() + F.substr(1);

if ($[D] != null) $[D](E)

};

SWFObject.registerASObject = function(A) {

var $ = A.swfId,

_ = A.asoId,

B = SWFObject.getSWFObject(A);

B.registerASObject(A)

};

ASObject = function($) {

this.swfId = $.swfId;

this.asoId = $.asoId;

this.swfObject = SWFObject.getSWFObject($);

if (ASObject.instances[this.swfId] == null) ASObject.instances[this.swfId] = {};

ASObject.instances[this.swfId][this.asoId] = this

};

ASObject.prototype.get = function($) {

return this.swfObject.getASObjectProperty({

asoId: this.asoId,

property: $

})

};

ASObject.prototype.set = function(_, $) {

this.swfObject.setASObjectProperty({

asoId: this.asoId,

property: _,

value: $

})

};

ASObject.prototype.call = function($, _) {

return this.swfObject.callASObjectMethod({

asoId: this.asoId,

method: $,

parameters: _

})

};

ASObject.instances = {};

Utils = {

g: function($) {

return document.getElementById($)

},

f: function(_) {

var $ = 'embed id="#{fid}" name="#{fid}" src="#{movie}" flashVars="#{flashVars}" width="#{width}" height="#{height}" align="#{align}" type="application/x-shockwave-flash" pluginspage="" wmode="#{wmode}" scale="#{scale}" salign="#{salign}" allownetworking="#{allownetworking}" allowscriptaccess="#{allowscriptaccess}" /',

A = 'object id="#{fid}" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="#{width}" height="#{height}" align="#{align}"param name="movie" value="#{movie}" /param name="flashVars" value="#{flashVars}" /param name="wmode" value="#{wmode}" /param name="scale" value="#{scale}" /param name="salign" value="#{salign}" /param name="allownetworking" value="#{allownetworking}" /param name="allowscriptaccess" value="#{allowscriptaccess}" //object';

this.g(_.cid).innerHTML = this.fm(this.b.isIE ? A: $, _)

},

fm: function($, _) {

if (arguments.length) if (typeof(_) == "object") $ = $.replace(/#\{([^\{\}]+)\}/g,

function(A, B) {

var $ = _[B];

if (typeof $ == "function") $ = $(B);

return typeof($) == "undefined" ? "": $

});

else if (typeof(_) != "undefined") for (var A = arguments.length - 2; A -1; A--) $ = $.replace(new RegExp("#\\{" + A + "\\}", "g"), arguments[A + 1]);

return $

},

b: {

isIE: /msie/i.test(navigator.userAgent),

isFF: /firefox/i.test(navigator.userAgent),

isMaxthon: (function() {

var $ = false;

try {

$ = external.max_version

} catch(_) {}

return $

})()

},

mo: function() {

var $ = {},

B = arguments.length;

for (var C = 0; C B; C++) {

var A = arguments[C];

for (var _ in A) {

if ($[_] != null) continue;

$[_] = arguments[C][_]

}

}

return $

}

};

HWR = {

loaded: false

};

HWR.load = function(E, C, D) {

HWR.tid = C;

var $ = D ? ("serviceUrl=" + D) : "",

B = {

cid: E,

fid: E + "_flash",

width: 410,

height: 290,

movie: "",

align: "middle",

salign: "lt",

wmode: "window",

scale: "noscale",

allowscriptaccess: "always",

allownetworking: "all",

flashVars: $

},

A = new SWFObject(B);

HWR.so = A;

var _;

A.onLoadInit = function($) {

HWR.ao = _ = A.asObjects.handWrite;

_.onCloseClick = function($) {

HWR._onCloseClick()

};

_.onCharSelect = function($) {

HWR._onCharSelect($["char"])

}

};

A.load()

};

HWR._onCharSelect = function(A) {

var $ = HWR.tid;

var G = $.selectionStart;

var H = $.selectionEnd;

$.value = $.value.substring(0,G) + A + $.value.substring(H,$.value.length);

$.selectionStart = G + A.length;

$.selectionEnd = G + A.length;

};

HWR._onCloseClick = function() {

if (HWR.onCloseClick) HWR.onCloseClick()

};

HWR.onCloseClick = null;

HWR.clear = function() {

HWR.ao.call("clear", [])

};

function getFlashVersion() {

var B = navigator;

if (B.plugins B.mimeTypes.length) {

var A = B.plugins["Shockwave Flash"];

if (A A.description) return A.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s)+r/, ".") + ".0"

} else if (window.ActiveXObject !window.opera) for (var C = 10; C = 2; C--) {

try {

var _ = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + C);

if (_) {

return C + ".0.0";

break

}

} catch($) {}

}

return "0"

}

function addStyle(A, $) {

var _ = document.styleSheets[0];

if (_.addRule) _.addRule(A, $);

else if (_.insertRule) _.insertRule(A + " { " + $ + " }", _.cssRules.length)

}

function penControl() {

var $ = parseInt(getFlashVersion());

if ($ 9) addStyle("#penControl", "display:none")

}

function stopClosePen($) {

$ = $ || window.event;

if ($.stopPropagation) $.stopPropagation();

else $.cancelBubble = true

}

var enablePen = false;

function openPen($) {

if (!enablePen) {

var A = document.getElementById(HWR.so.cfg.cid);

A.className = "hwr_visible_ujs";

enablePen = true

}

$ = $ || event;

var _ = $.target || $.srcElement;

_.blur();

stopClosePen($)

}

HWR.onCloseClick = function() {

HWR.clear();

var _ = document.getElementById(HWR.so.cfg.cid);

_.className = "hwr_hidden_ujs";

enablePen = false

};

function closePen($) {

var B = document.getElementById(HWR.so.cfg.cid);

$ = $ || event;

var A = $.target || $.srcElement;

if (enablePen) {

HWR.clear();

B.className = "hwr_hidden_ujs";

enablePen = false

}

}

function findPos(obj) {

var curleft = curtop = 0;

do {

curleft += obj.offsetLeft;

curtop += obj.offsetTop;

} while (obj = obj.offsetParent);

return [curleft, curtop];

}

function scrollDist() {

var html = document.getElementsByTagName('html')[0];

if (html.scrollTop document.documentElement.scrollTop) {

return [html.scrollLeft, html.scrollTop];

} else if (html.scrollTop || document.documentElement.scrollTop) {

return [html.scrollLeft + document.documentElement.scrollLeft, html.scrollTop + document.documentElement.scrollTop];

} else if (document.body.scrollTop)

return [document.body.scrollLeft, document.body.scrollTop];

return [0, 0];

}

function innerDimensions() {

if (self.innerHeight) {

return [self.innerWidth, self.innerHeight];

} else if (document.documentElement document.documentElement.clientHeight) {

return [document.documentElement.clientWidth, document.documentElement.clientHeight];

} else if (document.body)

return [document.body.clientWidth, document.body.clientHeight];

return [0, 0];

}

document.addEventListener('DOMContentLoaded',

function() {

hwrcss = '#hwr_div_ujs{position:absolute;}.hwr_hidden_ujs{display:none;}.hwr_visible_ujs{display:block;}';

var hwrstyle = document.createElement('style');

hwrstyle.setAttribute('type', 'text/css');

hwrstyle.textContent = hwrcss;

document.getElementsByTagName('head')[0].appendChild(hwrstyle);

hwrdiv = document.createElement('div');

hwrdiv.id = "hwr_div_ujs";

hwrdiv.className = "hwr_hidden_ujs";

document.body.appendChild(hwrdiv);

},

false);

document.documentElement.addEventListener('click',

function(e) {

if (e.ctrlKey !e.shiftKey !e.altKey) {

if (e.target.nodeName == "TEXTAREA" || e.target.type == "text" || e.target.type == "password") {

var tPos = findPos(e.target), wDim = innerDimensions(), sDis = scrollDist();

if (tPos[1] + 293 + e.target.offsetHeight - sDis[1] - wDim[1] 0) {

hwr_div_ujs.style.top = tPos[1] - 293 + "px";

} else {

hwr_div_ujs.style.top = tPos[1] + e.target.offsetHeight + 3 + "px";

}

hwr_div_ujs.style.left = Math.max(0, Math.min(tPos[0], wDim[0] - 430)) + "px";

hwr_div_ujs.className = "hwr_visible_ujs";

penControl();

HWR.load("hwr_div_ujs", e.target, "");

}

} else {

hwr_div_ujs.className = "hwr_hidden_ujs";

}

},

false);

Javascript的onblur事件如何手寫

document.getElementsById("文本框id").onblur=方法名如:=doit;//方法名不要加();把這個寫到onload事件中,

function doit()

{

}


網(wǎng)頁標題:javascript手寫,js手寫代碼
網(wǎng)站路徑:http://weahome.cn/article/dseeppe.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部