var ctx = document.querySelectorAll('canvas')[0].getContext('2d'); ctx.fillStyle = '#eee'; ctx.strokeStyle = 'blue'; ctx.beginPath(); ctx.moveTo(10, 10) ctx.lineTo(100, 10) ctx.lineTo(100, 100) ctx.lineTo(10, 100) ctx.lineTo(10, 10) ctx.closePath() ctx.stroke() ctx.fill();
ctx .fillStyle('#eee') .strokeStyle('blue') .beginPath() .moveTo(10, 10) .lineTo(100, 10) .lineTo(100, 100) .lineTo(10, 100) .lineTo(10, 10) .closePath() .stroke() .fill();
// (function(getContext, querySelectorAll, fillStyle, strokeStyle, beginPath, moveTo, lineTo, closePath, stroke, fill){ var canvasContext = $$(document)(querySelectorAll, 'canvas')(0)(getContext, '2d')(); $$(canvasContext, {fixedContext: true}) (fillStyle, '#eee') (strokeStyle, 'blue') (beginPath) (moveTo, 10, 10) (lineTo, 100, 10) (lineTo, 100, 100) (lineTo, 10, 100) (lineTo, 10, 10) (closePath) (stroke) (fill) (); }('getContext', 'querySelectorAll', 'fillStyle', 'strokeStyle', 'beginPath', 'moveTo', 'lineTo', 'closePath', 'stroke', 'fill'));
$$(canvasContext, {fixedContext: true}) (fillStyle, '#eee') (strokeStyle, 'blue') .beginPath() (moveTo, 10, 10) (lineTo, 100, 10) .lineTo(100, 100) (lineTo, 10, 100) (lineTo, 10, 10) (closePath) .stroke() .fill() ();
context = {'foo': {'bar': '100500'}, 'bar': '888', 'zoo': /./}; // {'foo': {'bar': '100500'}, 'bar': '888', 'zoo': /./} result = $$(context) ('foo') // {'bar': '100500'} ('bar', -1) // ('zoo') // zoo (); // - undefined .. foo / zoo
context = {'foo': {'bar': '100500'}, 'bar': '888', 'zoo': /./}; // {'foo': {'bar': '100500'}, 'bar': '888', 'zoo': /./} result = $$(context, {fixedContext: true}) ('foo') // {'bar': '100500'} ('bar', -1) // ('zoo') // zoo (); // - /./
context = {'foo': 1}; // {'foo': 1} result = $$(context) ('foo', 1000) // (function (context) { // return '' + context.foo / 2; // - '500' }) ('length') // (function (context) { return typeof context; // - 'number' }) (); // number
result = $$(document) ('getElementById', 'div1') ('style') ('width', '100px') // ({ // / height: '100px', color: 'red', border: 'solid 1px blue' }) (); // CSSStyleDeclaration Object
result = $$(jQuery) (['#div2']) // - , ('css', {width: '100px', height:'100px', color: 'red', border: 'solid 1px blue'}) ('animate', {width: '200px', height:'200px'}) (); // jQuery
$$.profile(); // console && console.dir($$.profileEnd());
[anonymous function] Object { calls=2, time=0} [context call] Object { calls=1, time=0} [switching context] Object { calls=7, time=0} animate Object { calls=1, time=5} bar Object { calls=2, time=0} width Object { calls=1, time=0}
$$([1,2,3]).length()();
can be - $$([1,2,3])('length')();
Source: https://habr.com/ru/post/115357/
All Articles