Skip to main content
deleted 178 characters in body; edited tags; edited title
Source Link
Deduplicator
  • 46k
  • 7
  • 73
  • 125

Add indent to a plain javascript code string Properly formatting JavaScript in JavaScript

Does anyone know/have a script or function to add indentation to javascript code? I've been searching for this on Google for quite some time now, andHow can I can't seem to find anything.automatically format JavaScript properly?

Basically what I need to do is make this, forAs an example, this:

(function(){(function(){alert('whatever')})()})()

BecomeShould become:

(function(){
    (function(){
        alert('whatever')
    })()
})()

Thanks in advance :)

Add indent to a plain javascript code string

Does anyone know/have a script or function to add indentation to javascript code? I've been searching for this on Google for quite some time now, and I can't seem to find anything.

Basically what I need to do is make this, for example:

(function(){(function(){alert('whatever')})()})()

Become:

(function(){
    (function(){
        alert('whatever')
    })()
})()

Thanks in advance :)

Properly formatting JavaScript in JavaScript

How can I automatically format JavaScript properly?

As an example, this:

(function(){(function(){alert('whatever')})()})()

Should become:

(function(){
    (function(){
        alert('whatever')
    })()
})()
Source Link
Tanner Ottinger
  • 3.1k
  • 4
  • 26
  • 29

Add indent to a plain javascript code string

Does anyone know/have a script or function to add indentation to javascript code? I've been searching for this on Google for quite some time now, and I can't seem to find anything.

Basically what I need to do is make this, for example:

(function(){(function(){alert('whatever')})()})()

Become:

(function(){
    (function(){
        alert('whatever')
    })()
})()

Thanks in advance :)