Skip to content

Instantly share code, notes, and snippets.

@wpweb101
wpweb101 / javascript-chained-method-calls.js
Created April 15, 2021 13:26
JavaScript Chained method calls
let myclass = new myClass()
.setvalue(2)
.setString('abc')
.setPrice(500)
.displayCart();
@wpweb101
wpweb101 / javaScript-multiline-statement.js
Last active April 15, 2021 13:19
JavaScript Multiline statement
var a;
var b;
var c;
// Good Example
var examplestring = 'this is example ' + a +
'string that spans into' + B +
'three lines' + c;
// Bad example
@wpweb101
wpweb101 / javaScript-blocks-brackets.js
Created April 15, 2021 13:01
JavaScript Blocks and Brackets
switch ( n ) {
case n1:
case n2:
x();
break;
case n3:
y();
break;
default:
z();
@wpweb101
wpweb101 / javaScript-indentation-line-break.js
Created April 15, 2021 12:52
JavaScript Indentation and Line Break
( function( $ ) { // Expression indented
// This doesn't get indented
function do_something() {
// Your logic
}
} )( jQuery );
@wpweb101
wpweb101 / javascript-good-spacing-example.js
Last active April 15, 2021 12:45
JavaScript good spacing example
var example;
if ( condition 1 ) { // use space before and after parenthesis
// write you code here // follow tabbing
} else if( condition 2 ) {
// write you code here
} else {
// write you code here
}
@wpweb101
wpweb101 / incorrect-input-values-for-style.css
Created April 15, 2021 12:36
InCorrect input values for style
#example {
font-family: Helvetika Neue, sans-serif; /* Quote font name*/
font-size:15px; /* Maintain space before property value */
padding:10px /* Missing semicolon*/
}
@wpweb101
wpweb101 / correct-input-values-for-style.css
Created April 15, 2021 12:32
Correct input values for style
#example {
font-family: "Helvetika Neue", sans-serif; /* Using double quotes */
font-size: 15px; /* End with semicolon*/
margin: 0 0 0 10px; /* Right use of 0 values*/
}
@wpweb101
wpweb101 / css-comments.css
Created April 15, 2021 12:21
Right CSS Comments
/* This is a single-line comment */
p {
color: red;
}
p {
color: red; /* Example for inline comment */
}
/* This is
@wpweb101
wpweb101 / autoprefixer-manages-browser-prefix.css
Created April 15, 2021 08:49
Autoprefixer manages browser prefix
a {
-webkit-transition: -webkit-transform 1s;
transition: -ms-transform 1s;
transition: transform 1s
}
@wpweb101
wpweb101 / style-properties-ordering-incorrect.css
Created April 15, 2021 08:46
Incorrect Style Properties Ordering
.container {
color: #fff;
position: relative;
font-size: 12px;
display: block;
padding: 5px;
}