Skip to content

Instantly share code, notes, and snippets.

@Oletem
Oletem / isNaN.js
Last active October 10, 2017 08:36
isNaN() Method. The Number.isNaN() method determines whether a value is NaN (Not-A-Number). This method returns true if the value is of the type Number, and equates to NaN. Otherwise it returns false. Number.isNaN() is different from the global isNaN() function. The global isNaN() function converts the tested value to a Number, then tests it. Nu…
Number.isNaN(123) //false
Number.isNaN(-1.23) //false
Number.isNaN(5-2) //false
Number.isNaN(0) //false
Number.isNaN('123') //false
Number.isNaN('Hello') //false
Number.isNaN('2005/12/12') //false
Number.isNaN('') //false
Number.isNaN(true) //false
Number.isNaN(undefined) //false
@Oletem
Oletem / .js
Created January 10, 2018 13:25
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found. Note: For the Array method, see Array.prototype.indexOf(). Syntax str.indexOf(searchValue[, fromIndex]) Parameters searchValue A string representing the va…
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.
Note: For the Array method, see Array.prototype.indexOf().
Syntax
str.indexOf(searchValue[, fromIndex])
Parameters
searchValue
A string representing the value to search for.
fromIndex Optional
An integer representing the index at which to start the search; the default value is 0. For fromIndex values lower than 0 or greater than str.length, the search starts at index 0 and str.length respectively.
@Oletem
Oletem / .js
Created January 10, 2018 13:53
Examples Examples of falsy values in JavaScript (which translate to false and thus bypass the if block): if (false) if (null) if (undefined) if (0) if (NaN) if ('') if ("") if (document.all) [1] [1] document.all has been used for browser detection in the past and the HTML specification defines a willful violation of the ECMAScript standard here …
_
@Oletem
Oletem / .js
Created January 10, 2018 15:44
:beginner: Basic Code Solution:
function getIndexToIns(arr, num) {
arr.sort(function(a, b) {
return a - b;
});
for (var a = 0; a < arr.length; a++) {
if (arr[a] >= num)
return a;
}
@Oletem
Oletem / .php
Created January 11, 2018 12:41
First, we create page-custom.php. Second, in the head we comment the name of template, that will be displayed and available to select in page attributes template => custom template selector. Then, in query, created in custom-page.php we can specify, what content will be displayed on this page More refernce: https://codex.wordpress.org/Class_Refe…
<?php
/**
* Template Name: Custom Template - how WP knows what the page is
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<article <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
@Oletem
Oletem / .htm
Created February 5, 2018 11:40
<form>
<th>
<label for = "Games">Games</label>
<tr>
<td>
<select id = "games">