• Skip to main content
  • Skip to search
  • Skip to select language
webdocs.dev
  • References
    • Overview / Web Technology

      Web technology reference for developers

    • HTML

      Structure of content on the web

    • CSS

      Code used to describe document style

    • JavaScript

      General-purpose scripting language

    • HTTP

      Protocol for transmitting web resources

    • Web APIs

      Interfaces for building web applications

    • Web Extensions

      Developing extensions for web browsers

    • Web Technology

      Web technology reference for developers

  • Guides
    • Overview / MDN Learning Area

      Learn web development

    • MDN Learning Area

      Learn web development

    • HTML

      Learn to structure web content with HTML

    • CSS

      Learn to style content using CSS

    • JavaScript

      Learn to run scripts in the browser

    • Accessibility

      Learn to make the web accessible to all

  • Play New
  1. WebAssembly
  2. WebAssembly instruction reference
  3. WebAssembly variable instructions
  4. Local set

In this article

  • Try it
  • Syntax
  1. WebAssembly home page
  2. Tutorials
    1. WebAssembly concepts
    2. Compiling from C/C++ to WebAssembly
    3. Compiling from Rust to WebAssembly
    4. Using the WebAssembly JavaScript API
    5. Understanding WebAssembly text format
    6. Converting WebAssembly text format to wasm
    7. Loading and running WebAssembly code
    8. Exported WebAssembly functions
  3. JavaScript interface
    1. WebAssembly
    2. WebAssembly.Module
    3. WebAssembly.Global
    4. WebAssembly.Instance
    5. WebAssembly.Memory
    6. WebAssembly.Table
    7. WebAssembly.Tag
    8. WebAssembly.Exception
    9. WebAssembly.CompileError
    10. WebAssembly.LinkError
    11. WebAssembly.RuntimeError

In this article

  • Try it
  • Syntax

Local set

The local.set instruction sets the values of a local variable.

Try it

Syntax

wasm

;; load the number 2 onto the stack
i32.const 2

;; store the number 2 in the variable $val
local.set $val
Instruction Binary opcode
local.set 0x21

Found a content problem with this page?

  • Edit the page on GitHub.
  • Report the content issue.
  • View the source on GitHub.
Want to get more involved? Learn how to contribute.

This page was last modified on Feb 23, 2023 by MDN contributors.

webdocs.dev
  • GitHub

Support

  • Report an issue

Our communities

  • Discord

Developers

  • Web Technologies
  • Learn Web Development

Portions of this content are ©1998–2023 by individual contributors. Content available under a Creative Commons license.