Archive for the 'javascript' Category

1 Feb 2019

javascript – Convert NodeList to Array

0:57 | javascript | 1030 views

Goal: work with nodeList as an array The nodeList is great but sometime we need to convert it to an array for the easy processing. old method old method – short form ES6 way – shorter form ES6 way – the shortest form enjoy… One more thing is a little bit strange. Check the speed […]


18 Apr 2018

use regions in MVS2015 for php files

13:12 | javascript, mvs, php | 1190 views

Goal: I want fold-able code for php like I have to js files The texteditor-like editors are great but without regions your life would be difficult. The Microsoft Visual Studio platform provides a very nice feature to use regions. The simpliest way is the following form – you can use it for javascript The php […]


28 Oct 2017

identify the type of an object

12:54 | javascript, web trick | 856 views

Goal: simple way to check the type of a page object I have found many answers about this question but the useless is much more than the valuable. There is a simple way to identify objects on the page. For example I have a click listener and I want to know the type of the […]


27 Oct 2017

swap two numbers

12:49 | javascript, tricky | 738 views

Goal: to enjoy he beauty of out of box thinking Everyday task to swap two numbers. Nothing easier like this, but do it in one line. The trickiest solution I have ever seen: ok, swap them this is it, simple beautiful


22 Oct 2017

get function name in strict mode

13:25 | javascript, tricky | 764 views

Goal: show the name of the called function in strict mode If I want to see the function name I can put it like this but I like the globalized solutions and don’t forget the strict mode, where the possibilities are restricted. There is nothing else to do just throw an exception and read from […]


15 Sep 2017

contenteditable – select all on double click

15:35 | javascript, jquery | 832 views

Goal: don’t be fool, do it easy A have a DIV with contenteditable=”true” attribute. Like a textbox but not really. I want to select all the content with a double click on it. With jQuery like this: … so do you know better than this solution? … I have read many scientific solution for this […]


27 Aug 2017

extend an array – js way

8:05 | javascript | 742 views

Goal: find the cleanest way to extend an array Everyday happening to extend an array in javascript. There are many ways to do but here is the simplest one 🙂 No more code, no more pain in the neck just an extended array. What we need more for today?


25 Mar 2017

javascript easy templates

13:51 | javascript, tricky | 753 views

Goal: build a quick template method So we have an item template and some values to replace. Do like this way. // 1. define the parser function template(strings, …keys) { return (function(…values) { var dict = values[values.length – 1] || {}; var result = [strings[0]]; keys.forEach(function(key, i) { var value = Number.isInteger(key) ? values[key] : […]


25 Mar 2017

javascript multiline strings in the code

13:40 | javascript, tricky | 793 views

Goal: use multiline strings in the code I have a simple string template. I want to store it in a variable but I want to forget the concatenation. We can use the following trick. var itemTemplate = `<li> <div class=”direction-r”> <div class=”flag-wrapper”> <span class =”flag”>${0}</span> <span class =”time-wrapper”>${1}</span> </div> <div class =”desc”>${2}</div> </div> </li>`; console.log(itemTemplate); […]


8 Mar 2017

Detect AD Blocker

2:09 | javascript | 731 views

Goal: do we have AD blocker or not? something like this: enjoy…


#sidebar a { color:#fff; } #sidebar ul ul li { color: #DEF585; } #sidebar h2 { color: #fff; } #sidebar ul p, #sidebar ul select { color: #BEDDBE; } #backfly { background: url(images/golfBallWallPaper.jpg) left bottom fixed repeat-x #65a51d; }