> ## Documentation Index
> Fetch the complete documentation index at: https://docs.js-confuser.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Moved Declarations

> Moves variable declarations to the top of the context.

* Option name: `"movedDeclarations"`

* Option values: `true/false/0-1`

***

### Input / Output

This example showcases how `Moved Declarations` transforms the code. Try it out by changing the input code and see changes apply in real-time.

```js title="Input.js" lines interactive-mode="obfuscate" theme={null}
// Input.js
function getAreaOfCircle(radius) {
  var pi = Math.PI;
  var radiusSquared = Math.pow(radius, 2);
  var area = pi * radiusSquared;

  return area;
}

console.log(getAreaOfCircle(3)); // 28.274333882308138

// Output.js
function iO4B5g(iO4B5g, Wz8bKds, Y3ezD0q, NQ8zpX) {
  Wz8bKds = Math.PI;
  Y3ezD0q = Math.pow(iO4B5g, 2);
  NQ8zpX = Wz8bKds * Y3ezD0q;
  return NQ8zpX;
}
console.log(iO4B5g(3));
```

***

### Usage Example

The provided code example will obfuscate the file `input.js` and write the output to a file named `output.js`.

```js title="Usage Example" lines theme={null}
import JSConfuser from "js-confuser";
import {readFileSync, writeFileSync} from "fs";

// Read input code
const sourceCode = readFileSync("input.js", "utf8");
const options = {
  target: 'browser',
  movedDeclarations: true,
};

JSConfuser.obfuscate(sourceCode, options).then((result)=>{
  // Write output code
  writeFileSync("output.js", result.code);
}).catch(err=>{
  // Error occurred
  console.error(err);  
});
```

***

#### Enabled In

* [High Preset](/presets/high): Yes
* [Medium Preset](/presets/medium): Yes
* [Low Preset](/presets/low): Yes
