@xobotyi
Nothing here yet.
Nothing here yet.
No blogs yet.
Python is not faster than PHP7, if you ment execution performance;) http://benchmarksgame.alioth.debian.org/u64q/php.html But if you are talking about performance of developing scripts for backend - yes, I found python a bit better language for it only because of massive built-in libraries amount.
I would show to user error message somewhere on the top of the screen or wherever it is appropriate for current app design. It MUST be noticeable, but not like.. covering the whole screen. In general, its almost as on web, just slightly different design maybe
For arrays (and objects btw) JS compares not vars values but pointers to its values in memory. In given example you have two different arrays in terms that they are two different objects of Array prototype and pointing to two different cells in memory. == or === in JS works as you think only for primitive types, but Array is generally a particular case of Object and for objects == or === compares only vars poiters to values (as explained above). Thats why (()=>{let a = [123], b=[123]; console.log(a==b, a===b);})(); will log false false and (()=>{let a = [123], b=a; console.log(a==b, a===b);})(); will log true true To compare arrays you can use some workarounds: 1) Dummy one: ( () => { let a = [ 123 ], b = [ 123 ]; console .log(a.toString() == b.toString()); // true console .log(a.toString() === b.toString()); // true })(); 2) A bit better one: (() => { let a = [ 123 ], b = [ 123 ]; console .log( a.length == b.length && a.every( function ( v, i ) { return v == b[i]; })); // true console .log( a.length == b.length && a.every( function ( v, i ) { return v === b[i]; })); // true })(); 3) The best one (IMO) (wrote for 5 minutes, so can contain issues) : Array .prototype.equals = function ( array2, strict = true, deep = false ) { if (!(array2 instanceof Array )) { throw Error ( 'Array can be equaled only with Array' ); } else if ( this .length !== array2.length) { return false ; } deep = !!deep; strict = !!strict; return this .every((v, i) => { if (v instanceof Array && deep) { return array2[i] instanceof Array ? v.equals(array2[i], strict, deep) : false ; } return strict ? v === array2[i] : v == array2[i]; }); }; (()=>{ let a = [ 123 , [ 123 , 321 ]], b = [ '123' , [ '123' , '321' ]]; console .log(a.equals(b)); // false console .log(a.equals(b, false )); // false console .log(a.equals(b, true , true )); //false console .log(a.equals(b, false , true )); //true })();
Hey there! My name is Anton Zinovyev and I am a software developer. I'm working with everything about WEB: front-end coding and designing and same with back-end. Primary stack: HTML, CSS, JS, PHP, PostgreSQL. For now i'm in the middle of searching myself as developer and trying to rethink the whole stack of used technologies. I hope that hashnode will become a good platform for it. Hope we will become friends, cheers! 🍻
My first PHP open-source lib. Helps to work with arrays in dot-notation style. https://github.com/xobotyi/dotarray I've been using such lib for a long time, but last week decided to make it as external opensource lib. Still have no proper readme yet (it is on the way), but the code is well documented. Feedback is appreciated!
isX functions, really helps to write less. Most common for me: function isBoolean ( v ) { return typeof v === 'boolean' ; } function isNumber ( v ) { return typeof v === 'number' ; } function isString ( v ) { return typeof v === 'string' ; } function isNumeric ( v ) { return isNumber(v) || (isString(v) && String (v * 1 ) === v); } function isSymbol ( v ) { return typeof v === 'symbol' ; } function isObject ( v ) { return v !== null && v === Object (v) && Object .prototype.toString.call(v) === '[object Object]' ; } function isFunction ( v ) { return v && typeof v === 'function' ; } function isArray ( v ) { return v && Array .isArray(v); } function isElement ( v ) { return v && v.tagName; } function isset ( v ) { return v !== null && typeof v !== 'undefined' ; }