Programming concepts

Versioned local record validation

Try the free JavaScript compiler

Application policy for distinguishing absent, invalid and valid stored records. The example is pure logic, not a database call.

Formal Syntax & Structure

javascript syntaxjavascript
restore(record)

Working Example

Example Snippetjavascript
(async () => {function restore(x){if(x===undefined)return "missing";return x&&x.version===1&&typeof x.text==="string"?"valid":"invalid";}console.log(restore(undefined),restore({version:2,text:"x"}),restore({version:1,text:"x"}));})()
JavaScript Reference