Joined October 2012

Alexey Raspopov

Zhitomir, UA

Posted to Intercepting JavaScript methods over 1 year ago

@viczam using _.wrap you will do the same as @anasnakawa wrote

Posted to Unique values in JavaScript Arrays over 1 year ago

@iam4x yep, it's slower than your solution, but when you haven't time to implement some new stuff like this you can just filter array :)

Posted to Unique values in JavaScript Arrays over 1 year ago

Or you can try something like this

[1, 2, 3, 4, 1].filter(function(item, index, all){
    return all.lastIndexOf(item) === index;
Posted to parseInt() can be dangerous over 1 year ago

Prevent this behavior using:

Prevent what? Hey, guys, are you fucking kidding me? RTFM. The second argument for parseInt is numeral system. When you ignore this argument, parseInt try to choose the most proper numeral system. So, when you call parseInt("023") (without second argument) you will get parsed integer in octal numeral system

parseInt("023", 8); // 19
parseInt("023", 10); // 23
Posted to JavaScript's Modulo over 1 year ago
var isOdd = function (n) { return !!(n % 2); };

I think it's easier :)

In first example you can write something like this:


It's really useful.
In some cases you'll realy need to use forEach method. For example, if you need a closure for your loop.

  var attribute = element.getAttribute('data-attr');
  element.onclick = function(){
Posted to Check for touch support over 1 year ago
  1. expression 'ontouchstart' in window will return boolean value and it's not required to create boolean manualy (using !!)

  2. expression window.hasOwnProperty('ontouchstart') is faster :)

var isMyObjectEmpty = !Object.keys(myObject).length;
Posted to Sublime Text 2: close tags shortcut over 1 year ago

In Windows it's Alt+.

Posted to Using Multiple Javascript Objects over 1 year ago

JavaScript doesn't have classes ;)

Posted to Brackets - Live Editor over 1 year ago

I prefer Sublime Text 2 + Live Reload
Brackets is good, but it hasn't a lot of features like in Sublime

57 Karma
2,413 Total ProTip Views
Interests & Skills