Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                aGlobalVariable ="my name is global"
var stillGlobal = _.map(_.range(2), function(){ return aGlobalVariable})

//lexical scope
aVar = "Outside"

function aFun(){
    var aVar = "Inside"
    
    return _.map(_.range(1,3,1), function(val){   
        var aVar = "InsideAnAnonym"
        return [aVar, val].join(" ")
    })
}

//this reference 
function globalThis(){ return this; }

var nopeThis = _.bind(globalThis, "nope")

//Function Scope

function strangeJS(n){
    var i;
    for(i =0; i < n; i++);
    return i;
}
//strangeJS(5) = 5
var n = 34
//wierder 
function checkIfGlobal(n){ 
  this["n"] = n;
  return this
}
//console.log(checkIfGlobal(5)) returns the Window/Global object
//console.log(checkIfGlobal.call({}, 5))  returns {n:5}

function f(){
  this["a"] = 1;
  return this["a"] + this["b"]
}

//console.log(f())  returns NaN
var g = {b:5}
///console.log(f.call(_.clone(g))) returns 6
//console.log(g) returns {b:5}

//closure  and free variables 
function Big(){
    var name = "Comfort Ajala"
    return function(){ return name + ", Hello there Girl!"} //local variable captured 
}
var reportName = Big()
//console.log(reportName()) prints "Comfort Ajala, Hello there Girl!"

function captureArgument(ar){
    return function(t){ return _.map(ar, function(val){ return val + t * 33 - 1 + ""})}
}

var arg = captureArgument([22,5,5667,88,3])
// console.log(arg(4)) ["153", "136", "5798", "219", "134"]
//----------------SHADOWING------------///
var name = "Freddy"
var name = "Tower"

//console.log(name) = Tower,bu

var shad = 0
function arshad(shad){ return ["Value is ", shad].join(" ")}

/*console.log(arshad()) = "Value is  "
console.log(arshad(6)) = "Value is  6"
*/

//captured value changes or nah
function isEven(n){ return n % 2 == 0 ?  "Even" : "Odd"}

function clap(fun){
  return function(n){return ["The number provided is ", fun(n)].join(" ")}
}

var calc = clap(isEven)
console.log(calc(4)) //"The number provided is  Even"
console.log(calc(5))//"The number provided is  Odd"
function isEven(n){ return 5 * 23;}

              
            
!
999px

Console