String to object const obj = JSON.parse(‘{“name”:”John”, “age”:30, “city”:”New York”}’); Copy object (not just put another pointer to it) let
Tag: JAVASCRIPT
Javascript Equivalent…
PHP preg_replace let phone=”+17778889999″; let p=phone.replace(/^\+1/,”); PHP isset if (typeof variable !== ‘undefined’) PHP array_pop path_arr.splice(-1,1); //note does not work
Javascript Debugging Tips
To dump out random objects console.log(JSON.stringify(obj)) if that didn’t work: console.log(“my object: %o”, obj); A straight console.log(obj) will often show
Javascript sleep function
Unlike the setTimeOut (functionName, delay) method which places the functionName in a queue then execute it after delay miliseconds, The
Okta Event Hooks
What are the Okta Event Hooks: Event Hooks are Okta’s implementation of the industry concept of webhooks Event Hooks are
Chrome Javascript Quick Note
To start Javascript console in Chrome: <ctrl><shift>J To force a hard refresh (which resets the javascript state, not just PHP’s)
Debug Browsers
Here’s a good website for how to invoke javascript debugger in different browsers: http://debugbrowser.com
Simple JS Demos
Click on one of the following items to see a simple demo of how HTML, CSS and Javascript/Jquery work together.
My JQUERY Cheat Sheet
Bind JQUERY UI Autocomplete to .Live Event Note: .Live is deprecated in JQUERY 1.7 $(‘.search’).live(‘keyup.autocomplete’, function(){ $(this).autocomplete({ source : ‘url.php’